# -*- coding: utf-8 -*-
# !/usr/bin/env python
from fastapi import APIRouter, Form
from typing import List
from starlette.requests import Request
from starlette.templating import Jinja2Templates
from starlette.responses import FileResponse
from starlette.staticfiles import StaticFiles
import os

router = APIRouter()
templates = Jinja2Templates(directory="templates")
router.mount("/static", StaticFiles(directory="./static"), name="static")


@router.get('/')
def show_chart(request: Request):
    return templates.TemplateResponse('./echarts/boxplot.html', {'request': request})


@router.post('/')
def show_charts(request: Request, data: str = Form(...),):
    data = [int(i) for i in data.split(',')]
    return templates.TemplateResponse('./echarts/boxplot.html', {'request': request, 'data':data})